<?php
namespace Admin\Controller;
use Think\Controller;

class IndexController extends BaseController {
	//登陆后默认进入此方法，显示整个页面
	public function index(){
		//加载整个后台页面,为了调用方便，我把它放在基类里了，你们以后继承基类BaseController就可以调用这个方法
    	$this->display('index');
	}

	public function head(){
		$this->display('head');
	}

	public function left(){
		//根据管理员id获取其本身信息
    	$admin_id = session("admin_id");
    	$admin_name = session("admin_name");;

    	$buss = M("Buss")->find($admin_id);
    	$role_id = $buss_info['bs_role_id'];
    	
    	//根据role_id获取本身记录信息
    	$role_info = M('Role')->find($role_id);
    	$auth_ids = $role_info['role_auth_ids'];
    	//根据auth_ids获取具体权限
    	if($admin_name == 'tom'){
    		//获取父级权限
	    	$auth_info_p = M('Auth')->where("auth_level=0")->select();
	    	//获得子级权限
	    	$auth_info_s = M('Auth')->where("auth_level=1")->select();
    	}else{
    		//获取父级权限
	    	$auth_info_p = M('Auth')->where("auth_level=0 and auth_id in ($auth_ids)")->select();
	    	//获得子级权限
	    	$auth_info_s = M('Auth')->where("auth_level=1 and auth_id in ($auth_ids)")->select();
    	}
        
        //将用户的权限菜单循环显示
    	$this->assign("auth_info_p",$auth_info_p);
		$this->assign("auth_info_s",$auth_info_s);
		$this->display('left');
	}

	public function right(){
		$this->display('right');
	}

	public function bottom(){
		$this->display('bottom');
	}
}
